/*********************************************************************************
 *      Copyright:  (C) 2022 Li Yanting<liyanting2@163.com>
 *                  All rights reserved.
 *
 *       Filename:  pub_json_data.c
 *    Description:  This file 
 *                 
 *        Version:  1.0.0(06/28/2022)
 *         Author:  Li Yanting <liyanting2@163.com>
 *      ChangeLog:  1, Release initial version on "06/28/2022 08:15:09"
 *                 
 ********************************************************************************/
#include "pack_data.h"

int pack_data(iotd_ctx_t *st_iotd, char *put_json_data)
{
    char             *msg;
    cJSON            *root;
    cJSON            *item;

    root =  cJSON_CreateObject();
    item =  cJSON_CreateObject();

    root = cJSON_CreateObject();
    cJSON_AddItemToObject(root, "params", item);
    cJSON_AddItemToObject(item, "CurrentTemperature", cJSON_CreateNumber(st_iotd->st_collect.temper));
    cJSON_AddItemToObject(root, "time", cJSON_CreateString(st_iotd->st_collect.time));

    msg = cJSON_Print(root);
    strcpy(put_json_data, msg);

    return 0;

}

